namespace Crux.Core.Query;
/// <summary>
///
/// </summary>
public record PageQuery : IQuery
{
    private int? pageIndex;
    private int? pageSize;
    /// <summary>
    /// 页码
    /// </summary>
    public int? PageIndex
    {
        get
        {
            switch (pageIndex)
            {
                case null:
                    return pageIndex;
                case > 0 when null != this.PageSize:
                    return pageIndex;
                default:
                {
                    if (null == this.PageSize)
                        throw new ArgumentNullException(nameof(PageSize));
                    break;
                }
            }

            throw new ArgumentNullException(nameof(PageIndex));
        }
        set => this.pageIndex = value;
    }
    /// <summary>
    /// 页大小
    /// </summary>
    public int? PageSize
    {
        get
        {
            if (null == pageSize || pageSize >= 0) return pageSize;
            throw new ArgumentNullException(nameof(PageSize));
        }
        set
        {
            this.pageSize = value;
        }
    }
}
